import gcRequest from '..'
import { checkStar, userStar } from './types'

export const getIsStar = (articleId: number) => {
  return gcRequest.post<checkStar.RootObject>({
    url: '/star/check',
    data: {
      articleId
    }
  })
}

export const addStar = (articleId: number) => {
  return gcRequest.post({
    url: '/star',
    data: {
      articleId
    }
  })
}

export const removeStarByArticleId = (articleId: number) => {
  return gcRequest.delete({
    url: '/star',
    data: {
      articleId
    }
  })
}

export const getUserStar = (offect: number, limit: number) => {
  return gcRequest.get<userStar.RootObject>({
    url: '/star/user',
    params: {
      offect,
      limit
    }
  })
}

export const removeStar = (starId: number) => {
  return gcRequest.delete({
    url: `/star/${starId}`
  })
}
